package math2;

import java.util.ArrayList;

/**
 * A function basis on the cube in n dimenstion. This is basically a set of
 * functions S = {v1, v2, ..., vn} where vi: R^n->R.
 * 
 * @author hbui
 */
public abstract class FunctionBasisOnRnToR implements Cloneable {

	protected ArrayList<FunctionRnToR> basis;

	public FunctionBasisOnRnToR() {
		basis = new ArrayList<FunctionRnToR>();
	}

	/**
	 * add a function to the basis
	 * 
	 * @param f
	 */
	public void addBasisFunction(FunctionRnToR f) {
		basis.add(f);
	}

	/**
	 * add an array of function to the basis
	 * 
	 * @param f
	 */
	public void addBasisFunction(FunctionRnToR... f) {
		for (int i = 0; i < f.length; i++) {
			basis.add(f[i]);
		}
	}

	/**
	 * Returns the specified basis function.
	 * 
	 * @param idx
	 *            index of the basis function
	 * @return the basis function
	 */
	public FunctionRnToR getBasisFunction(int i) {
		return basis.get(i);
	}

	/**
	 * Returns the number of basis functions.
	 * 
	 * @return the dimension
	 */
	public int getDimension() {
		return basis.size();
	}

	/**
	 * clone this basis.
	 */
	public abstract Object clone();
}
